<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Main extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model('leo');
    }

    function index() {
        $this->load->view('template/head');
        $this->load->view('template/header');
        $this->load->view('template/container');
        $this->load->view('template/footer');
    }

    function login() {
        $username = $this->input->post('username');
        $password = $this->input->post('password');
        $data['username'] = $this->security->xss_clean($username);
        $data['password'] = $this->security->xss_clean($password);
        $res = $this->leo->login($data);
        $ks = $res[0];
        echo $ks->username;
        if ($ks->previlege_id == 1) {
            $user = array(
                'username' => $this->input->post('username'),
                'log' => TRUE,
                'previlege_id' => '1'
            );
            $this->session->set_userdata($user);
            redirect('admin');
        } elseif ($ks->previlege_id == 2) {
            $user = array(
                'username' => $this->input->post('username'),
                'log' => TRUE,
                'previlege_id' => '2'
            );
            $this->session->set_userdata($user);
            redirect('member');
        } else {
            redirect();
        }
    }
    
    function register(){
        echo 'halaman register';
    }

}

/* End of file main.php */
/* Location: ./application/controllers/main.php */